// 防抖 -> 一段时间内只执行最后一次
function f(fn, delay = 1000) {
    let t = null;
    return function () {
        let _this = this;
        let args = arguments;
        if (t !== null) {
            clearTimeout(t);
        }
        t = setTimeout(function () {
            fn.apply(_this, [...args])
        }, delay)
    }
}
// 节流 -> 每隔一段时间执行一次
function j(fn, delay = 1000) {
    // 节流阀
    let flag = true;
    return function () {
        let _this = this;
        let args = arguments;
        if (flag) {
            flag = false;
            setTimeout(function () {
                fn.apply(_this, [...args]);
                flag = true;
            }, delay)
        }
    }
}
fangdou.onclick = f(function () {
    console.log("%c Line:14 🍇", "color:#93c0a4", '执行了');
}, 1000);
let i = 0;
jieliu.onclick = j(function () {
    i++;
    console.log("%c Line:30 🍌", "color:#33a5ff", '执行了', i);
}, 1000);